package source;

import source.view.*;

public class AreaEffect {
	private int effect;
	private boolean isDeath;
	private String picture;
	private AreaEffectType aType;
	
	public AreaEffect(AreaEffectType stats) {
		this.effect = stats.getEffect();
		this.isDeath = stats.getDeath();
		this.picture = stats.getPicture();
		this.aType = stats;
	}
	
	public boolean getIsDeath() {
		return isDeath;
	}
	
	public String getPicture() {
		return picture;
	}
	
	public AreaEffectType getType() {
		return aType;
	}	
	
	public boolean takeAction(Unit unit) {
		switch (this.aType) {
		case HEAL:
			MainScreen.writeToConsole("AreaEffect: Unit gets healed");
			unit.heal(this.effect);
			return false;
		case TAKEDAMAGE:
			if(!unit.takeDamage(this.effect)){
				unit.destroy();
				MainScreen.writeToConsole("AreaEffect: Unit is destroyed");
				return true;
			}
			MainScreen.writeToConsole("AreaEffect: Unit takes damage");
			return false;
		case INSTANTDEATH:
			unit.destroy();	// buh bye
			MainScreen.writeToConsole("AreaEffect: Unit is destroyed");
			return true;
		default:
			return false;
		}
	}
}
